package com.easycoding.framework.web.action;

import com.easycoding.framework.support.PageMan;




public class BeanPageAction extends BeanAction {


	/**
	 * 
	 */
	private static final long serialVersionUID = -4656619173544270039L;
	private int pageNo;
	private int totalPage;
	private int totalRow;
	private int pageSize;
	private int start;
	private int limit;
	private int pageStart;
	private int pageEnd;
	private int onePageNum;
	protected PageMan pageMan;
	
	public BeanPageAction() {
		pageMan = new PageMan();
		this.setPageNo(1);
		this.setTotalPage(0);
		this.setTotalRow(0);
		this.setOnePageNum(6);
		this.setPageSize(10);
	}

	protected PageMan getPageMan(int pageSize) {
		PageMan pm = new PageMan();
		this.pageSize = pageSize;
		totalPage = (totalRow - 1) / pageSize + 1;
		if (pageNo < 1)
			pageNo = 1;
		else if (pageNo > totalPage)
			pageNo = totalPage;
		pm.setPageSize(pageSize);
		pageStart = (pageNo-onePageNum/2)>1?(pageNo-onePageNum/2):1;
		pageEnd = (pageNo+(onePageNum-1)/2)>totalPage?totalPage:(pageNo+(onePageNum-1)/2);
		return pm;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
		pageMan.setPageNo(pageNo);
	}

	public int getPageNo() {
		return pageNo;
	}

	public int getTotalPage() {
		return totalPage;
	}

	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}

	public int getTotalRow() {
		return totalRow;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setTotalRow(int totalRow) {
		this.totalRow = totalRow;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
		pageMan.setPageSize(pageSize);
	}

	public void setStart(int start) {
		this.start = start;
	}

	public int getStart() {
		return start;
	}

	public void setLimit(int limit) {
		this.limit = limit;
	}

	public int getLimit() {
		return limit;
	}

	public void setPageStart(int pageStart) {
		this.pageStart = pageStart;
	}

	public int getPageStart() {
		return pageStart;
	}

	public void setPageEnd(int pageEnd) {
		this.pageEnd = pageEnd;
	}

	public int getPageEnd() {
		return pageEnd;
	}

	public void setOnePageNum(int onePageNum) {
		this.onePageNum = onePageNum;
	}

	public int getOnePageNum() {
		return onePageNum;
	}

	public PageMan getPageMan() {
		return pageMan;
	}

	public void setPageMan(PageMan pageMan) {
		this.pageMan = pageMan;
	}
}
